﻿using AutoMapper;
using Pay.Data;
using Pay.DTO;
using Pay.Core;
using Pay.IService;
using System.Collections.Generic;

namespace Pay.Service.AutoMapper {

    public class MerchantDeclarationMapper : IStartupDto {
        private IMapperConfigurationExpression _cfg;
        public MerchantDeclarationMapper(IMapperConfigurationExpression cfg) {
            _cfg = cfg;
        }
        public void Execute() {
            Create();
        }
        protected virtual void Create() {

            _cfg.CreateMap<MerchantDeclaration, merchant_declaration_dto>()
                .ForMember(dest => dest.id, src => src.MapFrom(c => c.Id))
                .ForMember(dest => dest.name, src => src.MapFrom(c => c.Name))
                .ForMember(dest => dest.mobile, src => src.MapFrom(c => c.Mobile))
                .ForMember(dest => dest.merchant_name, src => src.MapFrom(c => c.MerchantName))
                .ForMember(dest => dest.company_name, src => src.MapFrom(c => c.CompanyName))
                .ForMember(dest => dest.legal_person, src => src.MapFrom(c => c.LegalPerson))
                .ForMember(dest => dest.certificate1, src => src.MapFrom(c => c.Certificate1))
                .ForMember(dest => dest.certificate2, src => src.MapFrom(c => c.Certificate2))
                .ForMember(dest => dest.certificate_type, src => src.MapFrom(c => c.CertificateType))
                .ForMember(dest => dest.license, src => src.MapFrom(c => c.License))
                .ForMember(dest => dest.license_no, src => src.MapFrom(c => c.LicenseNo))
                .ForMember(dest => dest.overseas_bank_card, src => src.MapFrom(c => c.OverseasBankCard))
                .ForMember(dest => dest.card_url, src => src.MapFrom(c => c.CardUrl))
                .ForMember(dest => dest.country, src => src.MapFrom(c => c.Country))
                .ForMember(dest => dest.company_type, src => src.MapFrom(c => c.CompanyType))
                .ForMember(dest => dest.fee_count, src => src.MapFrom(c => c.FeeCount))
                .ForMember(dest => dest.auth_status, src => src.MapFrom(c => c.AuthStatus))
                .ForMember(dest => dest.create_time, src => src.MapFrom(c => c.CreateTime.ToDateTime()))
                .ForMember(dest => dest.review_time, src => src.MapFrom(c => c.ReviewTime.ToDateTime()));

            _cfg.CreateMap<merchant_declaration_dto, MerchantDeclaration>()
                .ForMember(dest => dest.Id, src => src.MapFrom(c => c.id))
                .ForMember(dest => dest.Name, src => src.MapFrom(c => c.name))
                .ForMember(dest => dest.Mobile, src => src.MapFrom(c => c.mobile))
                .ForMember(dest => dest.MerchantName, src => src.MapFrom(c => c.merchant_name))
                .ForMember(dest => dest.CompanyName, src => src.MapFrom(c => c.company_name))
                .ForMember(dest => dest.LegalPerson, src => src.MapFrom(c => c.legal_person))
                .ForMember(dest => dest.Certificate1, src => src.MapFrom(c => c.certificate1))
                .ForMember(dest => dest.Certificate2, src => src.MapFrom(c => c.certificate2))
                .ForMember(dest => dest.CertificateType, src => src.MapFrom(c => c.certificate_type))
                .ForMember(dest => dest.License, src => src.MapFrom(c => c.license))
                .ForMember(dest => dest.LicenseNo, src => src.MapFrom(c => c.license_no))
                .ForMember(dest => dest.OverseasBankCard, src => src.MapFrom(c => c.overseas_bank_card))
                .ForMember(dest => dest.CardUrl, src => src.MapFrom(c => c.card_url))
                .ForMember(dest => dest.Country, src => src.MapFrom(c => c.country))
                .ForMember(dest => dest.CompanyType, src => src.MapFrom(c => c.company_type))
                .ForMember(dest => dest.FeeCount, src => src.MapFrom(c => c.fee_count))
                .ForMember(dest => dest.AuthStatus, src => src.MapFrom(c => c.auth_status))
                .ForMember(dest => dest.CreateTime, src => src.MapFrom(c => c.create_time.ToUnix()))
                .ForMember(dest => dest.ReviewTime, src => src.MapFrom(c => c.review_time.ToUnix()));
        }
    }

}
